home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / keyboard.swg / 0043_Locking the Keyboard.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-08-27  |  966 b   |  58 lines

  1. {
  2. STEVEN TALLENT
  3.  
  4. You can disable the whole keyboard like this:
  5.  
  6. Sample program by Kerry Sokalsky
  7. }
  8.  
  9. Uses
  10.   KScreen;
  11.  
  12. Procedure KeyboardEnable; {unlocks keyboard}
  13. begin
  14.   Port[$21] := Port[$21] and 253;
  15.  end;
  16.  
  17. Procedure KeyboardDisable; {locks keyboard}
  18. begin
  19.   Port[$21] := Port[$21] or 2;
  20. end;
  21.  
  22. Var
  23.   X : Integer;
  24.  
  25. begin
  26.   ClrScr;
  27.  
  28.   KeyboardDisable;
  29.  
  30.   For X := 1 to 10000 do
  31.   begin
  32.     GotoXY(1,1);
  33.     Write(X);
  34.     If Keypressed then
  35.     begin
  36.       ClearBuffer;
  37.       gotoxy(10,10);
  38.       write('This should never occur! - ', X);
  39.     end;
  40.   end;
  41.  
  42.   ClearBuffer; { This is here because even though the keyboard is turned off,
  43.                  each key is still placed in the buffer }
  44.   KeyboardEnable;
  45.  
  46.   For X := 1 to 15000 do
  47.   begin
  48.     GotoXY(1,1);
  49.     Write(X);
  50.     If Keypressed then
  51.     begin
  52.       ClearBuffer;
  53.       gotoxy(10,10);
  54.       write('This could occur! - ', X);
  55.     end;
  56.   end;
  57.  
  58. end.